Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2131 - Make -ORBListenerInterfaces work properly as documented and tested #2132

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

nickwilliams-zaxiom
Copy link
Contributor

@nickwilliams-zaxiom nickwilliams-zaxiom commented Sep 21, 2023

See the detailed explanation for this change in #2131.

A quick note about this change: it includes a new test, $TAO_ROOT/orbsvcs/tests/Miop/McastListenerInterfaces. In order for this test to compile and run, $TAO_ROOT/TAO_ACE.mwc has to be edited to comment out or remove the line orbsvcs/tests in the exclude block. It seems that all orbsvcs tests are currently disabled in master. I did not include this change in my pull request, because it seems those tests were disabled for a reason, which I won't second-guess. I know, for example, that most of the tests in $TAO_ROOT/orbsvcs/tests/Miop/ fail on a clean master.

Summary by CodeRabbit

Based on the comprehensive changes, here are the release notes:

  • New Features

    • Enhanced network interface handling in ACE library
    • Added support for storing and retrieving interface names in network addresses
    • Improved multicast listener interface testing capabilities
  • Test Improvements

    • New test suite for multicast listener interfaces
    • Added comprehensive test scenarios for IPv4 and IPv6 network configurations
  • Bug Fixes

    • Refined network interface detection and address management
    • Improved error handling in network-related operations
  • Chores

    • Updated .gitignore to exclude macOS-specific files
    • Added new test configuration and helper scripts

The changes primarily focus on network interface management and testing infrastructure, with significant improvements to the ACE library's address handling capabilities.

@jwillemsen
Copy link
Member

I wouldn't put all gitignore files as part of this PR, when you want to add that, make that a separate PR. Also by using the C++ uniform initialization, std::unique_ptr, std instead of ACE_OS this could be more modern C++.

I haven't looked at the issue in detail, this probably needs some detailed review, also the fact that you mention that your approach is maybe not the best will trigger review

@nickwilliams-zaxiom
Copy link
Contributor Author

I wouldn't put all gitignore files as part of this PR, when you want to add that, make that a separate PR.

Done in #2133. The changes will disappear from here when that's merged and this is rebased.

Also by using the C++ uniform initialization, std::unique_ptr, std instead of ACE_OS this could be more modern C++.

Do you have specific callouts? I actually took pains to use the same techniques, tools, and styles used elsewhere in the code that I was changing, because it was not clear to me which things (like unique_ptr) were and were not allowed, or even which C++ standard (C++11, C++17, etc.) this master is targeting.

I haven't looked at the issue in detail, this probably needs some detailed review, also the fact that you mention that your approach is maybe not the best will trigger review

I certainly welcome the review. I came up with the best solution that I knew how to, but I do not know this code nearly as well as do you, and it's possible that you just want to do it a different way, or maybe you'll even do a complete refactor of the affected areas to achieve other goals I'm not aware of.

I resolved the Fuzz issues, and I worked through all the Codacy issues that I thought were valid. Two of them are clearly false positives caused by the use of the ACE_ERROR_RETURN macro. The other is, I believe, also a false positive, but it may go away based on resolution of my question above ("Do you have specific callouts?"), i.e. I may made this a std::string instead of a char *. I'm torn on the CodeFactor issues, because they are indeed complex methods, but they were already complex methods, and there are even-more complex methods in that file. Refactoring them to be less-complex (splitting into multiple methods) might not be worth the effort.

I'm waiting on platform-specific build results now.

@mitza-oci
Copy link
Member

Should "ORBListener" by replaced by "ORBListen"? See TAO/docs/ORBEndpoint.html for established usage.

@jwillemsen
Copy link
Member

Master requires c++14 or newer

@jwillemsen
Copy link
Member

New test should be added to bin/lst file

ACE/ace/INET_Addr.cpp Outdated Show resolved Hide resolved
@nickwilliams-zaxiom
Copy link
Contributor Author

nickwilliams-zaxiom commented Sep 28, 2023

New test should be added to bin/lst file

I can't find a file named lst, so this must be short for something I don't understand. Could you elaborate?

I just found TAO/bin/tao_other_tests.lst. I'll add it there.

@nickwilliams-zaxiom nickwilliams-zaxiom force-pushed the ORBListenerInterfaces_IPv6_fix branch from a86a104 to 8cceee4 Compare October 9, 2023 19:15
@nickwilliams-zaxiom
Copy link
Contributor Author

I've rebased to remove all the unrelated .gitignore additions, and responded to the above comments with several refactors. The two remaining Codacy issues are clear false positives. The CodeFactor issues are a subjective matter of opinion that I welcome feedback on. I can provide additional refactorings to simplify these functions/methods, but I'm worried about the scope creeping too much on this change. I think it's good to merge as-is, but will proceed however requested.

One thing I did notice through all of this work is that there are about half a dozen different places that use getifaddrs and/or GetAdaptersAddresses to go through interfaces and addresses, and many of them have the same if windows do this else do that macro logic. A major refactor that could be a benefit would be to extract this into a set of platform-generic C++11-modern helper classes, which would simplify many functions/methods, including the two mentioned by CodeFactor. However, that would touch a lot of major areas in excess of the minimum areas needed to fix this issue, so I'm not comfortable proceeding with that without some kind of prior approval.

@jwillemsen
Copy link
Member

Please open a new issue for the getifaddrs/GetAdaptersAddresses proposal, that way it doesn't get lost.

@nickwilliams-zaxiom
Copy link
Contributor Author

It's been 16 months since this pull request was proposed and 15 months since all code review comments were addressed. Is there anything stopping it from being merged?

@jwillemsen
Copy link
Member

jwillemsen commented Jan 29, 2025

It's been 16 months since this pull request was proposed and 15 months since all code review comments were addressed. Is there anything stopping it from being merged?

I lack time to do a final review (only did a partial review) and check all builds/tests to make sure nothing breaks by accident.

@nickwilliams-zaxiom
Copy link
Contributor Author

I lack time to do a final review and check all builds/tests to make sure nothing breaks by accident.

All tests pass with this change. The pull request summary page used to reflect that, but it seems that the build configuration for pull requests has been removed or disabled, so the build results are no longer visible. I get the desire to want to make sure nothing breaks by accident, but that's a theoretical problem up against something that is known to be broken: IPv6 is not currently fully supported in TAO. This pull request fixes that known broken feature. I did all the heavy lifting of debugging and researching the problem, experimenting with various fixes, implementing a fix, extensively documenting the problem and my fix, adding new tests for my fix, and making various adjustments in response to your initial review comments. This pull request represents approximately three weeks of my effort. In return for my effort, I would hope you could be a good steward of the open source community by finding one hour of time over a period of 16 months to review the pull request and merge it.

@jwillemsen
Copy link
Member

I appreciate all pull requests, issues, feedback but at the end of the month @RemedyIT has to pay its bills. We do a lot of work for free for the ACE/TAO community but that time is getting more and more limited. I find your PR a higher risk one on a first check and I really would need to sit down and go through all the details, setup some builds and check the results (the github actions only compile the core of ACE/TAO, none of the tests and compiled and/or executed, that these are green says not much). That will all together really take more than one hour, you have to wait until I can find some free time or see if you fund the review/test, see https://github.com/DOCGroup/ACE_TAO/wiki/ACE-and-TAO-Commercial-support.

All wchar/ascii conversions in your patch are something I find suspicious, wchar to ascii means just remove 50% of the data, converting back from ascii to wchar means adding all 0 bytes.

Copy link

coderabbitai bot commented Jan 31, 2025

Walkthrough

This pull request introduces enhancements to network interface handling across multiple components of the ACE and TAO libraries. The changes primarily focus on adding interface name management capabilities to network address classes, improving multicast address handling, and introducing a new test suite for multicast listener interfaces. The modifications span several files, including .gitignore, network address implementation files, and a new test module for verifying multicast listener functionality.

Changes

File Change Summary
.gitignore Added .DS_Store entry
ACE/ace/INET_Addr.h/.cpp Added interface name management methods:
- get_interface_name() method
- set_interface_name() method
- New if_name_ member variable
ACE/ace/SOCK_Dgram.cpp Updated multicast interface handling methods:
- Improved make_multicast_ifaddr and make_multicast_ifaddr6
- Enhanced interface name and IP address processing
ACE/ace/Sock_Connect.cpp Added interface name setting in get_ip_interfaces_getifaddrs
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/ New test module with:
- IDL definition
- Server and client implementations
- Interface address helper utility
- Test configuration and run script

Sequence Diagram

sequenceDiagram
    participant Client
    participant Server
    participant NetworkInterface
    participant ORB

    Client->>Server: Initialize with specific interface
    Server->>NetworkInterface: Set interface name
    Server->>ORB: Configure listener interfaces
    Client->>Server: Shutdown request
    Server->>ORB: Perform shutdown
Loading

Poem

🐰 Interfaces dancing, network's delight,
Addresses hopping with newfound might!
From loopback to ethernet, names now shine bright,
ACE and TAO leaping to networking's height!
Multicast magic, a rabbit's pure glee! 🌐

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (16)
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/if_addrs_helper.cpp (5)

1-16: Consider consolidating includes and verifying macro usage.

The sequence of includes and macro definitions is correct for each platform, but consider grouping them more cohesively (e.g., Windows- or POSIX-specific) to improve readability. Additionally, verify that IPV4_MIN_LENGTH and IPV6_MIN_LENGTH reflect realistic minimal string lengths in all cases (for example, IPv6 addresses can include scope IDs which may extend the string).


29-54: Provide RAII-like handling and thorough error reporting.

The WinsockHelper constructor and destructor correctly manage Winsock initialization/cleanup. However, consider:

  • Reporting detailed error messages or returning an error code in addition to printing to std::cout.
  • Wrapping the class usage in more robust RAII structures if expanded for more complex logic in the future.

169-205: Ensure robust error handling in address_to_string.

While the function gracefully handles conversion failures from WSAAddressToStringW, consider:

  1. Logging the target family (IPv4/IPv6) during errors for better diagnostics.
  2. Handling scope IDs for IPv6 addresses, if relevant to your use case.

206-298: Break out detection logic into reusable functions.

The main function logically enumerates adapters, determines interface types (loopback vs. Ethernet), and terminates once it finds each combination. This logic is correct but can be split into smaller functions to ease testing and maintenance (e.g., a function to process a single adapter).


301-433: Unify Windows and POSIX code paths if feasible.

The POSIX path largely duplicates the Windows logic. To reduce duplication, consider creating a common API for enumerating interfaces, then providing separate small platform-specific implementations. This DRY approach simplifies maintenance and testing for both platforms.

TAO/orbsvcs/tests/Miop/McastListenerInterfaces/Test.idl (1)

1-12: Add documentation or comments around the shutdown operation.

While the IDL is minimal and correct, adding a brief comment explaining the behavior and constraints of shutdown (e.g., any additional completion notifications) can help future maintainers understand the interface requirements.

TAO/orbsvcs/tests/Miop/McastListenerInterfaces/Test_impl.cpp (1)

4-8: Confirm exception handling around _duplicate.

The constructor usage of CORBA::ORB::_duplicate is standard, but consider how exceptions (e.g., if orb is null) will be handled. At minimum, log or assert that orb is valid, to help diagnose misconfiguration.

TAO/orbsvcs/tests/Miop/McastListenerInterfaces/Test_impl.h (1)

1-2: Consider using _H instead of _HPP for header guards

While both work, using _H is more common in the ACE/TAO codebase for consistency.

-#ifndef TEST_IMPL_HPP
-#define TEST_IMPL_HPP
+#ifndef TEST_IMPL_H
+#define TEST_IMPL_H
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/McastListenerInterfaces.mpc (2)

19-21: Remove empty IDL_Files blocks

Empty IDL_Files blocks can be removed as they serve no purpose.

-  IDL_Files {
-  }

Also applies to: 31-33


38-39: Remove empty Header_Files block

Empty Header_Files block can be removed.

-  Header_Files {
-  }
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/README (1)

1-15: Improve README formatting

The content is clear but could benefit from better formatting:

  1. Add a title section
  2. Use markdown formatting for better readability
+# McastListenerInterfaces Test
+
+## Purpose
 This test verifies the proper behavior of the -ORBListenerInterfaces option on IPv4 and IPv6 with values *=ip_addr,
 *=interface_name, and CopyPreferredInterfaces. The latter requires also using the -ORBPreferredInterface option.
 
+## Test Procedure
 It does so by doing the following:
 
-1. Calling the local helper utility if_addrs_helper to determine the system name of the loopback interface and
+1. Calls the local helper utility `if_addrs_helper` to determine the system name of the loopback interface and
    ethernet-like interface(s) with routable IPv4 and IPv6 addresses, as well as the correct IP addresses for those
    interfaces.
 
-2. Creating a matrix of tests across these interfaces, IP addresses, and the *=ip_addr, *=interface_name, and
+2. Creates a matrix of tests across these interfaces, IP addresses, and the `*=ip_addr`, `*=interface_name`, and
    CopyPreferredInterfaces option values.
 
-3. Executing the matrix of tests and asserting a specific failure (but no other failures) for loopback interfaces and
+3. Executes the matrix of tests and asserts a specific failure (but no other failures) for loopback interfaces and
    no failures for non-loopback interfaces. Specifically, for loopback interfaces, the server process should never
    receive the instruction to shut down from the client, and so the test should time out waiting on the server process
    and elect to kill it.
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/client.cpp (1)

6-6: Avoid global variables

Consider encapsulating the IOR in a class or passing it as a parameter.

TAO/orbsvcs/tests/Miop/McastListenerInterfaces/server.cpp (1)

39-129: Consider adding error handling for memory allocation.

The server implementation looks good overall, but there's a potential memory leak risk if ACE_NEW_RETURN fails after orb->resolve_initial_references() succeeds.

Consider using RAII with unique_ptr:

-      Server_impl* server_obj = 0;
-      ACE_NEW_RETURN (server_obj,
-                      Server_impl(orb.in()),
-                      3);
-      PortableServer::ServantBase_var owner (server_obj);
+      std::unique_ptr<Server_impl> server_obj(new Server_impl(orb.in()));
+      PortableServer::ServantBase_var owner(server_obj.release());
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/run_test.pl (1)

139-288: Consider adding test timeout configuration.

The test execution logic is solid, but consider making the timeout values configurable through environment variables for debugging purposes.

Add timeout configuration:

+my $DEFAULT_TIMEOUT = 60;  # seconds
+my $test_timeout = $ENV{TEST_TIMEOUT} || $DEFAULT_TIMEOUT;
ACE/ace/INET_Addr.h (1)

441-441: Consider initializing if_name_ in constructor.

While nullptr initialization is fine, consider moving it to the constructor for consistency with other member initializations.

ACE/ace/SOCK_Dgram.cpp (1)

Line range hint 764-897: Consider refactoring IPv6 address lookup logic.

The IPv6 address lookup logic is complex and could benefit from being split into a separate method for better maintainability.

Consider extracting the IPv6 address lookup into a separate method:

private:
  int find_ipv6_interface_index(const char* net_if_char, const in6_addr& net_if_in6_addr) {
    // Move the IPv6 lookup logic here
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 408bd95 and beef835.

📒 Files selected for processing (16)
  • .gitignore (1 hunks)
  • ACE/ace/INET_Addr.cpp (2 hunks)
  • ACE/ace/INET_Addr.h (3 hunks)
  • ACE/ace/SOCK_Dgram.cpp (6 hunks)
  • ACE/ace/Sock_Connect.cpp (2 hunks)
  • TAO/bin/tao_other_tests.lst (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/.gitignore (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/McastListenerInterfaces.mpc (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/README (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/Test.idl (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/Test_impl.cpp (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/Test_impl.h (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/client.cpp (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/if_addrs_helper.cpp (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/run_test.pl (1 hunks)
  • TAO/orbsvcs/tests/Miop/McastListenerInterfaces/server.cpp (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🔇 Additional comments (14)
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/if_addrs_helper.cpp (1)

56-109: Validate buffer reallocation loop and handle partial failures.

The buffer reallocation loop for GetAdaptersAddresses is straightforward; however:

  1. Ensure partial allocations don't mask other errors (e.g., repeated ERROR_BUFFER_OVERFLOW could point to abnormal behavior).
  2. Consider logging the iteration count to ease debugging under extreme conditions.
TAO/orbsvcs/tests/Miop/McastListenerInterfaces/Test_impl.cpp (1)

9-12: Consider a try-catch block for the shutdown.

The shutdown(false) call might throw exceptions in certain ORB configurations or states. Depending on the system requirements, ensure you have a plan for gracefully handling such exceptions (even if it's logging).

TAO/orbsvcs/tests/Miop/McastListenerInterfaces/server.cpp (1)

10-37: LGTM! Well-structured argument parsing.

The command-line argument parsing is well-implemented with clear error handling and usage messages.

TAO/orbsvcs/tests/Miop/McastListenerInterfaces/run_test.pl (2)

1-97: LGTM! Robust test configuration setup.

The test configuration setup is thorough, with proper error handling for the if_addrs_helper command and comprehensive interface type detection.


99-137: LGTM! Well-documented helper functions.

The helper functions are well-documented and handle their specific tasks effectively.

ACE/ace/INET_Addr.h (2)

22-24: LGTM! Appropriate header includes.

The addition of memory and string headers is appropriate for the new functionality.


289-304: LGTM! Well-documented interface name methods.

The new methods are well-documented with clear explanations of their informational purpose.

ACE/ace/SOCK_Dgram.cpp (1)

Line range hint 652-723: LGTM! Improved interface name handling.

The changes properly handle both interface names and IP addresses, with good fallback behavior for older Linux kernels.

ACE/ace/INET_Addr.cpp (3)

316-319: LGTM! Good use of modern C++.

The copy constructor properly handles the interface name copying using std::shared_ptr, with appropriate null checking.


1009-1013: LGTM! Clean getter implementation.

The method correctly returns a shared_ptr to const string, maintaining const correctness and memory safety.


1015-1026: LGTM! Well-implemented setter with proper null handling.

The method correctly handles both null and non-null cases, using modern C++ features like make_shared.

ACE/ace/Sock_Connect.cpp (1)

610-610: LGTM! Consistent interface name handling for both IPv4 and IPv6.

The implementation properly sets interface names for both address families using the new functionality.

Also applies to: 623-625

TAO/bin/tao_other_tests.lst (1)

242-242: LGTM! Test entry properly configured.

The test entry has appropriate configuration flags consistent with other MIOP tests in the list.

TAO/orbsvcs/tests/Miop/McastListenerInterfaces/.gitignore (1)

1-8: LGTM! Comprehensive gitignore entries.

The file correctly lists all expected generated files and build artifacts for the test directory.

Comment on lines +126 to +168
bool
is_link_local (const struct in6_addr * a)
{
// fe80::/64
return (a->s6_bytes[0] == 0xfe &&
a->s6_bytes[1] == 0x80 &&
a->s6_words[1] == 0 &&
a->s6_words[2] == 0 &&
a->s6_words[3] == 0);
}

bool
is_site_local (const struct in6_addr * a)
{
// fec0::/16
return (a->s6_bytes[0] == 0xfe &&
a->s6_bytes[1] == 0xc0);
}

bool
is_v4_mapped (const struct in6_addr * a)
{
// ::ffff:0:0/96
return (a->s6_words[0] == 0 &&
a->s6_words[1] == 0 &&
a->s6_words[2] == 0 &&
a->s6_words[3] == 0 &&
a->s6_words[4] == 0 &&
a->s6_words[5] == 0xffff);
}

bool
is_v4_translated (const struct in6_addr * a)
{
// ::ffff:0:0:0/96
return (a->s6_words[0] == 0 &&
a->s6_words[1] == 0 &&
a->s6_words[2] == 0 &&
a->s6_words[3] == 0 &&
a->s6_words[4] == 0xffff &&
a->s6_words[5] == 0);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use standardized IPv6 macros for classification.

All helper functions (is_link_local, is_site_local, is_v4_mapped, is_v4_translated) replicate functionality offered by macros such as IN6_IS_ADDR_LINKLOCAL, etc. While your custom checks may be valid, standardized macros reduce the risk of bitwise errors and increase maintainability.

Comment on lines +111 to +124
bool
is_loopback (const struct in6_addr * a)
{
// ::1
return (a->s6_words[0] == 0 &&
a->s6_words[1] == 0 &&
a->s6_words[2] == 0 &&
a->s6_words[3] == 0 &&
a->s6_words[4] == 0 &&
a->s6_words[5] == 0 &&
a->s6_words[6] == 0 &&
a->s6_bytes[14] == 0 &&
a->s6_bytes[15] == 0x01);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Confirm endianness assumptions for IPv6 loopback checks.

These byte and word checks in is_loopback rely on raw struct fields. Typically, IPv6 addresses are stored in network byte order. Validate that these checks succeed on little-endian and big-endian systems. If strict portability is required, consider using standard macros like IN6_IS_ADDR_LOOPBACK.

Proposed fix example:

-bool is_loopback (const struct in6_addr * a)
-{
-  return (a->s6_words[0] == 0 && ... && a->s6_bytes[15] == 0x01);
-}
+bool is_loopback (const struct in6_addr * a)
+{
+  return IN6_IS_ADDR_LOOPBACK(a);
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bool
is_loopback (const struct in6_addr * a)
{
// ::1
return (a->s6_words[0] == 0 &&
a->s6_words[1] == 0 &&
a->s6_words[2] == 0 &&
a->s6_words[3] == 0 &&
a->s6_words[4] == 0 &&
a->s6_words[5] == 0 &&
a->s6_words[6] == 0 &&
a->s6_bytes[14] == 0 &&
a->s6_bytes[15] == 0x01);
}
bool
is_loopback (const struct in6_addr * a)
{
return IN6_IS_ADDR_LOOPBACK(a);
}

Comment on lines +6 to +15
class Server_impl : public virtual POA_Test::Server
{
public:
Server_impl (CORBA::ORB_ptr orb);

virtual void shutdown ();

private:
CORBA::ORB_var orb_;
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add virtual destructor and class documentation

The class is missing:

  1. A virtual destructor which is necessary for proper cleanup when deleting through base class pointer
  2. Documentation explaining the class purpose and method behavior
+/**
+ * @class Server_impl
+ * @brief Implementation of the Test::Server interface
+ */
 class Server_impl : public virtual POA_Test::Server
 {
 public:
   Server_impl (CORBA::ORB_ptr orb);
+  virtual ~Server_impl() = default;
 
   virtual void shutdown ();
 
 private:
   CORBA::ORB_var orb_;
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class Server_impl : public virtual POA_Test::Server
{
public:
Server_impl (CORBA::ORB_ptr orb);
virtual void shutdown ();
private:
CORBA::ORB_var orb_;
};
/**
* @class Server_impl
* @brief Implementation of the Test::Server interface
*/
class Server_impl : public virtual POA_Test::Server
{
public:
Server_impl (CORBA::ORB_ptr orb);
virtual ~Server_impl() = default;
virtual void shutdown ();
private:
CORBA::ORB_var orb_;
};

Comment on lines +45 to +46
Test::Server_var server =
Test::Server::_unchecked_narrow (tmp.in ());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use _narrow instead of _unchecked_narrow

_unchecked_narrow skips type checking which could lead to runtime errors. Use _narrow for type-safe conversion.

-    Test::Server::_unchecked_narrow (tmp.in ());
+    Test::Server::_narrow (tmp.in ());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Test::Server_var server =
Test::Server::_unchecked_narrow (tmp.in ());
Test::Server_var server =
Test::Server::_narrow (tmp.in ());

Comment on lines +53 to +54
orb->destroy ();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add proper cleanup in error paths

The ORB should be destroyed even when errors occur. Consider using RAII or ensure cleanup in all paths.

 try
   {
     CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
 
     if (parse_args (argc, argv) != 0)
-      ACE_ERROR_RETURN ((LM_ERROR, "Wrong arguments\n"), 2);
+    {
+      orb->destroy();
+      ACE_ERROR_RETURN ((LM_ERROR, "Wrong arguments\n"), 2);
+    }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +40 to +41
if (parse_args (argc, argv) != 0)
ACE_ERROR_RETURN ((LM_ERROR, "Wrong arguments\n"), 2);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add nullptr check for ior_server

Need to verify ior_server is not null before using it.

 if (parse_args (argc, argv) != 0)
   ACE_ERROR_RETURN ((LM_ERROR, "Wrong arguments\n"), 2);
+
+if (ior_server == nullptr)
+  ACE_ERROR_RETURN ((LM_ERROR, "No IOR specified\n"), 2);

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Needs to be reviewed
Development

Successfully merging this pull request may close these issues.

TAO_UIPMC_Protocol_Factory's -ORBListenerInterfaces does not work with IPv6 addresses and has other issues
3 participants